﻿<form id="frmBXJGCMSArticle" class="frm-container">
    <input type="hidden" name="id" value="0" />
    <table class="frm-box">
        <tr>
            <th>所属栏目</th>
            <td colspan="5" >
                <input name="columnId" class="easyui-combotree"
                       data-options="
                       width:200,
                       required:true,
                       url:abp.appPath+'api/services/app/BXJGCMSColumn/GettreeForSelect',
                       queryParams: { forType: 4 }" />
            </td>
        </tr>
        <tr>
            <th>标题</th>
            <td colspan="5" >
                <input name="title" class="easyui-textbox" data-options=" required:true, validType:'length[1,200]',prompt:'文章标题'" />
            </td>
        </tr>
        <tr>
            <th>SEO标题</th>
            <td colspan="5" >
                <input name="seoTitle" class="easyui-textbox" data-options="  validType:'length[1,2000]',prompt:'seo标题'" />
            </td>
        </tr>
        <tr>
            <th>SEO关键字</th>
            <td colspan="5" >
                <input name="seoKeyword" class="easyui-textbox" data-options=" validType:'length[1,2000]',prompt:'seo关键字'" />
            </td>
        </tr>
        <tr>
            <th>SEO描述</th>
            <td colspan="5" >
                <input name="seoDescription" class="easyui-textbox" data-options=" validType:'length[1,2000]',prompt:'seo描述信息'" />
            </td>
        </tr>
        <tr>
            <th class="top">摘要</th>
            <td colspan="5" >
                <input name="summary" class="easyui-textbox" data-options="multiline:true, height:100, validType:'length[1,2000]',prompt:'摘要信息'" style="padding-top:5px;" />
            </td>
        </tr>
        <tr>
            <th>发布</th>
            <td><input class="easyui-checkbox" name="published" data-options="value:true"></td>
            <th>发布开始时间</th>
            <td><input class="easyui-datetimebox" name="publishStartTime" data-options="showSeconds1:false,prompt:'发布开始时间，可不设置'"></td>
            <th>发布结束时间</th>
            <td><input class="easyui-datetimebox" name="publishEndTime" data-options="showSeconds1:true,prompt:'发布结束时间，可不设置'"></td>
        </tr>
        <tr>
            <th class="top">详细描述</th>
            <td colspan="5" style="padding-top:7px; ">
                <div id="BXJGCMSArticleEditor0" style="border: 1px solid #ddd;"></div>
                <div id="BXJGCMSArticleEditor" style="width:700px; height:600px;border: 1px solid #ddd;"></div>
            </td>
        </tr>
    </table>
</form>
<script>
    (function () {
        let m = 'BXJGCMSArticle';
        let $dlg = $('#dlg' + m);
        let $frm = $dlg.find('form');
        let id = $dlg.data('id');
        let $name = $frm.find('[name="name"]');
        let $cls = $frm.find('[name="columnId"]');

        setTimeout(function () {
            $name.next('span').find('input').focus();
        }, 0);

        $dlg.data('clickSave', function () {
            if (!$frm.form('validate'))
                return;

            var postData = $frm.serializeJSON();
            
            postData.content = editor.txt.html();
            var defer;
            if (id) {
                defer = abp.services.app.bXJGCMSArticle.update(postData).done(function (d) {
                    abp.notify.success(abp.localization.bxjgUtils('修改') + abp.localization.bxjgUtils('成功') + '!');
                    onSaved('onUpdated');
                });
            } else {
                defer = abp.services.app.bXJGCMSArticle.create(postData).done(function (d) {
                    abp.notify.success(abp.localization.bxjgUtils('新增') + abp.localization.bxjgUtils('修改') + '!');
                    onSaved('onAdded');
                });
            }
            abp.ui.setBusy($dlg, defer);
        });

        if (id) {
            abp.ui.setBusy($dlg, abp.services.app.bXJGCMSArticle.get({ id: id }).done(function (d) {
                $frm.form('load', d);
                editor.txt.html(d.content);
            }));
        } else
            $cls.val($dlg.data('clsId'));//直接用val赋值，easyui初始化后会直接使用这个值初始化对应的控件

        function onSaved(funcName) {
            var f = $dlg.data(funcName);
            if (f)
                f();
        }

        //富文本编辑器开始---------------------------------
        var E = window.wangEditor
        var editor = new E('#BXJGCMSArticleEditor0', '#BXJGCMSArticleEditor')
        // 或者 var editor = new E( document.getElementById('editor') )

        editor.customConfig.uploadImgShowBase64 = true;
        editor.create();
        //富文本编辑器结束---------------------------------
    })();
</script>
